<template>
  <view>
    <view class="input-search">
    	<uni-easyinput prefixIcon="search"  trim="all" v-model="keyword" :styles="styles" :placeholderStyle="placeholderStyle"></uni-easyinput>
		<button @click="search">搜索</button>
    </view>
    
    <!-- stripe type="selection" 开启多选 -->
    <uni-table ref="table" type="" stripe :loading="loading" border emptyText="暂无更多数据" filter-type="search">
        <uni-tr v-for="(item, index) in card_arr" :key="index" >
			<uni-td width="100%" align="left" class="td-class" >
				<div @click="selectes(item)" class="td_div">
					<view class="td_list">
						<text class="label">名称：</text>
						<text class="text">{{ item.fName }}</text>
					</view>
					<view class="td_list">
						<text class="label">编码：</text>
						<text class="text">{{ item.fNumber }}</text>
					</view>
					<!-- <view class="td_list">
						<text class="label">联系人：</text>
						<text class="text">{{ item.fContact }}</text>
					</view> -->
				</div>
			</uni-td>
          </uni-tr>
    </uni-table>
    <view class="uni-pagination-box">
		<uni-pagination show-icon :page-size="pageSize" :current="currentPage"
        :total="total" @change="change" />
	</view>
  </view>
</template>

<script>
// 引入uni-ui组件
import {
  uniPagination,
  uniIcons,
  uniCard,
  uniTable,
  uniTr,
  uniTh,
  uniTd,
  uniEasyinput
} from "@dcloudio/uni-ui"
//import scanCode from "@/component/scan-code.vue"
export default {
  data() {
    return {
      card_arr: [],//当前页码的表格数据
      pageSize: 15,// 每页数据量
      currentPage: 1,// 当前页
      total: 0,// 数据总量
      loading: false,
      id: '',
	  placeholderStyle:'font-size:17px;',
	  styles:{
	  	borderColor: '#999'
	  },
	  keyword:'',
	  where:'',
	  
	  //在线版
	  config:uni.getStorageSync('myconfig'),
	  pageinfo:{},
	  user:uni.getStorageSync('user')
	  //
    }
  },
  components: {
    uniPagination,
    uniIcons, //uni-ui的icons组件
    uniCard, //uni-ui的卡片组件
    uniTable,
    uniTr,
    uniTh,
    uniTd,
	uniEasyinput//,scanCode
  },
  onPullDownRefresh() {
  	this.search()
  	uni.stopPullDownRefresh();
  },
  methods: {
    radioChange(e) {
      var value = Number(e.detail.value);
      this.id = this.card_arr[value].id
    },
    // 点击关闭的事件回调
    close() {
      uni.navigateBack({})
    },
    selectes(item) {
      if (item == '') return
	  uni.navigateBack({
		delta: 1,
		success: () => {
		  uni.$emit("getSupplier", item)
		}
	  });
    },
	// 搜索
	search() {
		this.currentPage = 1;
		this.getlist();
	},
    //获取列表
    getlist() {
		//20231204在线版
		this.pageinfo = {
			table:'supplier',
			pagesize:this.pageSize,
			page:this.currentPage,
			order_str:'',
			condition_str:JSON.stringify({
			  'keyword':this.keyword,
			})
		}
		uni.showLoading({mask:true})
		this.$Api.getPageList(this.pageinfo).then(res=>{
			this.card_arr = res.data.data_item
			this.total = res.data.data_totle
			this.currentPage = res.data.page_index+1
			uni.hideLoading();
		}).catch(err=>{
			this.$Api.msg(err)
		})
    },
    change(e) {
      this.currentPage = e.current
      this.getlist()
    }
  },
  mounted(e) {
    this.getlist()
  },
  onLoad(e) {
	this.flag = e.flag
	this.getlist()
	this.$Func.setBarTitle('供应商列表')
  }
}
</script>
<style lang="less">
</style>